/**
 * Add linkage to Bitmap in the Library (CS4+ only)
 * CS3 has a bug when setting linkageExportForAS to true
 */

fl.outputPanel.clear();
var doc = fl.getDocumentDOM();
var lib = doc.library;
var itemArray = lib.items;

function exportForAS()
{
	var len = itemArray.length;
	for (var i=0;i<len;i++) 
	{
		var myItem = itemArray[i];
		var myItemType = myItem.itemType;
		
		lib.selectItem(myItem.name, true);
		var libraryItems = lib.getSelectedItems();
		
		if(myItemType == 'bitmap')
		{
			var curPath = myItem.name;
			var slopeIndex = curPath.lastIndexOf("/");
			var folderName = curPath.substr(0, slopeIndex);
			var fileName = curPath.substr(slopeIndex + 1, curPath.length - slopeIndex);
		
			fl.trace(libraryItems + " / " +  fileName);
			//myItem.name = folderName + "_" + fileName;
			try
			{
				//libraryItems[0].linkageExportForRS = true;
				//libraryItems[0].linkageExportInFirstFrame = true;
				//libraryItems[0].linkageImportForRS = false;
				//libraryItems[0].linkageExportForRS = false;
				
				libraryItems[0].linkageExportForAS = true;
				libraryItems[0].linkageExportForRS = false;
				libraryItems[0].linkageExportInFirstFrame = true;
				libraryItems[0].linkageClassName = fileName;
				libraryItems[0].linkageBaseClass = "flash.display.BitmapData";
				
				fl.trace(libraryItems[0].linkageExportForAS);
			}
			catch(error)
			{
				fl.trace(error);
			}
		}
	}
}

exportForAS();